<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>登录-思多客</title>
    <link href="http://cdn.bootcss.com/normalize/7.0.0/normalize.min.css" rel="stylesheet">
    <link rel="stylesheet" href="/public/css/m/public.css">
    <link rel="stylesheet" href="/public/css/m/login-register.css">
</head>

<body>
    <div class="n-page">
        <div class="new-header flex">
            <!-- <div class="back-box">
                <img src="/public/images/m/back.png" alt="" class="left-back-icon">
            </div> -->
            <span class="header-title flex-child-box">登录</span>
        </div>
        <div class="login-content">
            <div class="center-logo-box">
                <img src="/public/images/m/logo-h.png" alt="" class="logo-icon">
                <span>传播智慧,&nbsp;传承分享</span>
            </div>
            <div class="login-form">
                <input type="text" placeholder="用户名" class="form-input" id="J_username">
                <input type="password" placeholder="密码" class="form-input" id="J_pwd">
                <div class="login-btn" id="J_login">登录</div>
                <p class="tips-box center">没有账号？ 去<a href="/m/register.html" class="reg-btn">注册</a></p>
            </div>
            <p class="other-login-type">第三方账号登录</p>
            <div class="gologin-btn">
                <img class="J_oauth_button" src="/public/images/qq-icon.png" alt="" data-type="qq">
                <!-- <img id="J_test" src="/public/images/wechat-icon.png" alt="" data-type="wx"> -->
                <!-- <img class="J_oauth_button" src="/public/images/alipay-icon.png" alt="" data-type="alipay"> -->
            </div>
        </div>
    </div>
    <script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script src="/public/js/m/fontResize.js"></script>
    <script src="/public/js/G.js"></script>
    <script src="/public/js/user.js"></script>
    <script src="/public/js/m/public.js"></script>
    <script>
    $('#J_login').click(function() {
        var username = $('#J_username').val().trim();
        var pwd = $('#J_pwd').val().trim();
        console.log(username, pwd)
        if (!username) {
            alert('请输入用户名');
            return;
        }
        if (!pwd) {
            alert('请输入登录密码');
            return;
        }
        var params = {
            username: username,
            secretkey: pwd
        }
        loading.open()
        user.login(params, function(data) {
            var time = 60 * 24 * 1;
            var path = G.getQuery('from');
            G.setCookie('jwt', data.jwt, time)
            G.setCookie('sdk_user_id', data.user.userId, time)
            G.setCookie('sdk_user_type', data.user.userType, time)
            G.setCookie('sdk_user_avator', data.user.avatorUrl, time)
            setTimeout(function() {
                loading.close()
                if(path != 'undefined'){
                    location.href = '/m/' + path + location.search;
                }else{
                    location.href = '/m/index.html';
                }
            }, 500)
        }, function(err) {
            console.error(err)
            loading.close()
            alert(err)
        })
    })
    $(document).on("click", ".J_oauth_button", function() {
        var type = $(this).data("type");
        var url = G.apiurl + "oauth2/" + type + "Mobile/authorize.do";
        console.log(url)
        location.href = url;
    })
    </script>
</body>

</html>